<template>
  <div v-loading="loading" :element-loading-text="loadtext">
    <h1>{{title}}</h1>
    <div style="border: 1px solid #CCCCCC">
      <v-report-header></v-report-header>
      <el-row>
        <el-col :span="4">
          <div class="grid-content bg-purple">指标名称</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content bg-purple">代码</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">人数（人次）</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">人数（人天）</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">指标名称</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content bg-purple">代码</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">人数（人次）</div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="4">
          <div class="grid-content bg-purple">甲</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content bg-purple">乙</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">本季01</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">本季01</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">甲</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content bg-purple">乙</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple">本季01</div>
        </el-col>
      </el-row>
      <el-row v-for="(item,index) in zzcjarr" :key="item.code" v-if="index < 21">
        <el-col :span="4">
          <div class="grid-content bg-purple">{{item.title}}</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content bg-purple">{{item.code}}</div>
        </el-col>
        <div v-if="index === 0">
          <el-col :span="4">
            <div class="grid-content">
              <el-input :disabled="true" value="--------"></el-input>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content">
              <el-input-number style="width:100%;" v-model="zzcjarr[index].data[1]" :min="0" :controls="false" @change="changeStoreArray"></el-input-number>
            </div>
          </el-col>
        </div>
        <div v-else>
          <el-col :span="4">
            <div class="grid-content" v-if="item.readonly">
              <el-input :disabled="true" value="--------"></el-input>
              
            </div>
            <div class="grid-content" v-else>
              <el-input-number style="width:100%;" :disabled="item.readonly" v-model="zzcjarr[index].data[0]" :min="0" :controls="false" @change="changeStoreArray"></el-input-number>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content">
              <el-input :disabled="true" value="--------"></el-input>
            </div>
          </el-col>
        </div>
        <el-col :span="4">
          <div class="grid-content bg-purple">{{zzcjarr[index+21].title}}</div>
        </el-col>
        <el-col :span="2">
          <div class="grid-content bg-purple">{{zzcjarr[index+21].code}}</div>
        </el-col>
        <el-col :span="4">
          <div class="grid-content bg-purple" v-if="zzcjarr[index+21].readonly">
            <el-input :disabled="true" value="--------"></el-input>
          </div>
          <div class="grid-content bg-purple" v-else>
            <el-input-number style="width:100%;" v-model="zzcjarr[index+21].data[0]" :disabled="zzcjarr[index+21].readonly" :controls="false" @change="changeStoreArray"></el-input-number>
          </div>
        </el-col>
      </el-row>
    </div>
    <el-row>
      <el-col :span="24">
        <p style="padding:10px;float:left;">备注说明</p>
      </el-col>
      <el-col :span="24">
        <el-input type="textarea" :rows="3" @input="$emit('getZzcjDataDes',$event)"></el-input>
      </el-col>
    </el-row>
    <v-buttons @getInputLength="queryInput" @countTourismPeoples="countTourism"></v-buttons>
  </div>
</template>
<script>
import { mapGetters, mapActions } from 'vuex'
import { cleanInput } from '../util'
import vReportHeader from './ReportHeader.vue'
import vButtons from './Buttons.vue'
export default {
  components: {
    vReportHeader, vButtons
  },
  props: [
    'title'
  ],
  computed:{
    ...mapGetters(['zzcjs']),
  },
  methods: {
    ...mapActions(['setZzcjArray']),
    queryInput() {
      cleanInput(this.$el.querySelectorAll("input"));
    },
    changeStoreArray(){
      this.setZzcjArray(this.zzcjarr);
    },
    countTourism() {
      this.loading = true;
      this.loadtext = '数据保存中，请稍后...';
      setTimeout(() => {
        this.changeStoreArray();
        sessionStorage.setItem("zzcjarr", JSON.stringify(this.zzcjarr));
        this.loading = false;
      }, 500);
    }
  },
  mounted() {
    if (sessionStorage.getItem("zzcjarr")) {
      this.zzcjarr = JSON.parse(sessionStorage.getItem('zzcjarr'));
    }
  },
  data() {
    return {
      loading: false,
      loadtext: '',
      zzcjarr: [
        {
          title: '出境游客',
          code: '01',
          readonly: true,
          data: [0, 0]
        }, {
          title: '亚洲小计',
          code: '02',
          readonly: true,
          data: [0]
        }, {
          title: '香港地区',
          code: '03',
          readonly: false,
          data: [0]
        }, {
          title: '澳门地区',
          code: '04',
          readonly: false,
          data: [0]
        }, {
          title: '台湾地区',
          code: '05',
          readonly: false,
          data: [0]
        }, {
          title: '日本',
          code: '06',
          readonly: false,
          data: [0]
        }, {
          title: '韩国',
          code: '07',
          readonly: false,
          data: [0]
        }, {
          title: '蒙古',
          code: '08',
          readonly: false,
          data: [0]
        }, {
          title: '印度尼西亚',
          code: '09',
          readonly: false,
          data: [0]
        }, {
          title: '马来西亚',
          code: '10',
          readonly: false,
          data: [0]
        }, {
          title: '菲律宾',
          code: '11',
          readonly: false,
          data: [0]
        }, {
          title: '新加坡',
          code: '12',
          readonly: false,
          data: [0]
        }, {
          title: '泰国',
          code: '13',
          readonly: false,
          data: [0]
        }, {
          title: '印度',
          code: '14',
          readonly: false,
          data: [0]
        }, {
          title: '越南',
          code: '15',
          readonly: false,
          data: [0]
        }, {
          title: '缅甸',
          code: '16',
          readonly: false,
          data: [0]
        }, {
          title: '亚洲其他',
          code: '17',
          readonly: false,
          data: [0]
        }, {
          title: '欧洲小计',
          code: '18',
          readonly: true,
          data: [0]
        }, {
          title: '英国',
          code: '19',
          readonly: false,
          data: [0]
        }, {
          title: '法国',
          code: '20',
          readonly: false,
          data: [0]
        }, {
          title: '德国',
          code: '21',
          readonly: false,
          data: [0]
        }, {
          title: '意大利',
          code: '22',
          readonly: false,
          data: [0]
        }, {
          title: '瑞士',
          code: '23',
          readonly: false,
          data: [0]
        }, {
          title: '瑞典',
          code: '24',
          readonly: false,
          data: [0]
        }, {
          title: '俄罗斯',
          code: '25',
          readonly: false,
          data: [0]
        }, {
          title: '西班牙',
          code: '26',
          readonly: false,
          data: [0]
        }, {
          title: '荷兰',
          code: '27',
          readonly: false,
          data: [0]
        }, {
          title: '丹麦',
          code: '28',
          readonly: false,
          data: [0]
        }, {
          title: '欧洲其他',
          code: '29',
          readonly: false,
          data: [0]
        }, {
          title: '美洲小计',
          code: '30',
          readonly: true,
          data: [0]
        }, {
          title: '美国',
          code: '31',
          readonly: false,
          data: [0]
        }, {
          title: '美洲其他',
          code: '32',
          readonly: false,
          data: [0]
        }, {
          title: '大洋洲小计',
          code: '33',
          readonly: true,
          data: [0]
        }, {
          title: '澳大利亚',
          code: '34',
          readonly: false,
          data: [0]
        }, {
          title: '新西兰',
          code: '35',
          readonly: false,
          data: [0]
        }, {
          title: '大洋洲其他',
          code: '36',
          readonly: false,
          data: [0]
        }, {
          title: '非洲小计',
          code: '37',
          readonly: true,
          data: [0]
        }, {
          title: '南非',
          code: '38',
          readonly: false,
          data: [0]
        }, {
          title: '埃及',
          code: '39',
          readonly: false,
          data: [0]
        }, {
          title: '肯尼亚',
          code: '40',
          readonly: false,
          data: [0]
        }, {
          title: '非洲其他',
          code: '41',
          readonly: false,
          data: [0]
        }, {
          title: '其他小计',
          code: '42',
          readonly: false,
          data: [0]
        },
      ]
    }
  }
}
</script>
